var createTree = function(res) {
	var html = "";
	var getNode = function(nodeName, subHtml) {

		var style = "";
		if ($.isFunction(subHtml)) {
			subHtml = subHtml();
		}

		if (subHtml != "") {
			style = "folder";
		}

		return "<li><span class='" + style + "' ><a href='javascript:;'>" + nodeName + "</a></span>"
				+ subHtml + "</li>";
	};

	$(res['modList']).each(function(i, mod) {
				html += getNode(mod['name'], function() {
							var str = "<ul>";
							$(mod['popedoms']).each(function(i, pope) {
										str += getNode(pope['popedomName'], "");
									});
							str += "</ul>";
							return str;
						});
			});

	$("#treeLeft").html(html).treeview();

};

$(function() {
			$.ajax({
						type : "post",
						url : "/swss/user/findAllPopedom.action",
						dataType : "json",
						success : function(res) {
							// alert(res);
							createTree(res);
						}
					});
					
			$("#btnSave,#btnDel").button();

		});